<?php defined('InShopNC') or exit('Access Invalid!');?>

<div class="tabmenu">
<!-- 201261220周家财修改 添加团购链接-->
  <?php include template('layout/submenu');?>
<?php if ($output['isOwnShop']) { ?>
  <a href="<?php echo urlShop('store_groupbuy', 'groupbuy_add_vr'); ?>" style="right:100px" class="ncsc-btn ncsc-btn-green" title="新增虚拟商品抢购"><i class="icon-plus-sign"></i>新增虚拟抢购</a>
  
   <a href="<?php echo urlShop('store_groupbuy', 'bef_groupbuy_add');//echo urlShop('store_groupbuy', 'groupbuy_add');?>" class="ncsc-btn ncsc-btn-green" title="<?php echo $lang['groupbuy_index_new_group'];?>">
  <i class="icon-plus-sign"> </i>
  <?php echo $lang['groupbuy_index_new_group'];?></a> 
  <?php } else { ?>

  <?php if(!empty($output['current_groupbuy_quota'])) { ?>
  <a href="<?php echo urlShop('store_groupbuy', 'groupbuy_add_vr'); ?>" style="right:200px" class="ncsc-btn ncsc-btn-green" title="新增虚拟商品抢购"><i class="icon-plus-sign"></i>新增虚拟抢购</a>
  <a href="<?php echo urlShop('store_groupbuy', 'bef_groupbuy_add');//echo urlShop('store_groupbuy', 'groupbuy_add');?>" style="right:100px" class="ncsc-btn ncsc-btn-green" title="<?php echo $lang['groupbuy_index_new_group'];?>">
  <i class="icon-plus-sign"></i>
  <?php echo $lang['groupbuy_index_new_group'];?></a>
  <a class="ncsc-btn ncsc-btn-acidblue" href="<?php echo urlShop('store_groupbuy', 'groupbuy_quota_add');?>" title="套餐续费"><i class="icon-money"></i>套餐续费</a>
  <?php } else { ?>
  <a class="ncsc-btn ncsc-btn-acidblue" href="<?php echo urlShop('store_groupbuy', 'groupbuy_quota_add');?>" title="购买套餐"><i class="icon-money"></i>购买套餐</a>
  <?php } ?>
<?php } ?>
											
<a class="ncsc-btn ncsc-btn-acidblue" href="<?php echo urlShop('store_groupbuy', 'set_team_template',array('groupbuy_id' => $_GET['group_id']));?>" title="设置拼团"><i class="icon-money"></i>设置拼团</a>

</div><!-- 201261220周家财修改 添加团购链接-->
<table class="ncsc-default-table">
  <thead>
    <tr>
      <th class="w10"></th>
     <!--  <th class="w50"></th> -->
      <th class="w80">团购活动id</th>
      <th class="w80">活动商品id</th>
      <th class="w100">团购活动名称</th>
      <th class="w120">开始时间</th>
      <th class="w120">结束时间</th>
      <th class="w160">商品名称</th>
      <th class="w90">商品原价</th>
      <!-- <th class="w90">拼团价格</th> -->
     <!--  <th class="w90">操作</th> -->
    </tr>
  </thead>
  <tbody>

    <tr class="bd-line">
      <td></td>
      <td>
         <?php echo $output['groupbuy_detail']['groupbuy_id'];?>
      </td>
      <td>
         <?php echo $output['groupbuy_detail']['goods_id'];?>
      </td>
      <td>
         <?php echo $output['groupbuy_detail']['groupbuy_name'];?>
      </td>
      
      <td id='start_time'><?php echo date('Y-m-d H:i:s',$output['groupbuy_detail']['start_time']);?></td>
      
      <td id='end_time'><?php echo date('Y-m-d H:i:s',$output['groupbuy_detail']['end_time']);?></td>
      
      <td id='range_start'><?php echo $output['groupbuy_detail']['goods_name'];?></td>
      
      <td id='range_end'><?php echo $output['groupbuy_detail']['goods_price'];?></td>
      
      <!-- <td><input name="price_list"  type="radio" class="price_check" value="<?php //echo $price['range_id'];?>" ></td> -->
    </tr>
   
  </tbody>

</table>
<hr/>
<br>
<div style="height: 30px; color: blue; font-size:16px;">拼团模板</div>
<table class="ncsc-default-table" >
  <thead>
    <tr>
      <th class="w10"></th>
     <!--  <th class="w50"></th> -->
      <th class="w80">拼团模板ID</th>
      <th class="w100">团购活动ID</th>
      <th class="w100">模板名称</th>
      <th class="w100">成团人数</th>
      <th class="w100">团长价格</th>
	<th class="w100">团员价格</th>
    </tr>
  </thead>
  <tbody>
 <?php if ($output['team_template']=='还没设置拼团模板'){?>
   <div style="height: 30px; color: blue; font-size:16px;"><?php echo $output['team_template'];?></div>
   <?php }else{ ?>
     <tr class="bd-line">
      <td></td>
      
      <td>
         <?php echo $output['team_template']['team_template_id'];?>
      </td>
      <td>
         <?php echo $output['team_template']['groupbuy_id'];?>
      </td>
       <td>
         <?php echo $output['team_template']['team_template_name'];?>
      </td>
       <td>
         <?php echo $output['team_template']['team_template_num'];?>
      </td>
      <td>
         <?php echo $output['team_template']['team_template_lead_price'];?>
      </td>
      
      <td ><?php echo $output['team_template']['team_template_member_price'];?></td>
      
     
      <?php }?>
 
  </tbody>

</table>
<hr/>
<br>
<div style="height: 30px; color: blue; font-size:16px;">拼团列表</div>

<table class="ncsc-default-table" >
  <thead>
    <tr>
      <th class="w10"></th>
     <!--  <th class="w50"></th> -->
      <th class="w80">拼团ID</th>
      <th class="w100">团购活动ID</th>
      <th class="w100">团长ID</th>
      <th class="w100">团长名称(团名)</th>
      <th class="w100">成团人数</th>
      <th class="w120">开始时间</th>
      <th class="w120">结束时间</th>
      <th class="w160">审核状态</th>

    </tr>
  </thead>
  <tbody>

   <?php if ($output['team_list']=='还没有拼团'){?>
   <div style="height: 30px; color: blue; font-size:16px;"><?php echo $output['team_list'];?></div>
   <?php }else{ foreach ($output['team_list'] as $key =>$list) {?>
     <tr class="bd-line">
      <td></td>
      
      <td>
         <?php echo $list['team_id'];?>
      </td>
      <td>
         <?php echo $list['groupbuy_id'];?>
      </td>
       <td>
         <?php echo $list['lead_id'];?>
      </td>
       <td>
         <a href=<?php echo $list['mem_url'];?>>
         <?php echo $list['lead_name'];?>
         </a>
      </td>
      <td>
         <?php echo $list['team_number'];?>
      </td>
      
      <td ><?php echo date('Y-m-d H:i:s',$list['start_time']);?></td>
      
      <td ><?php echo date('Y-m-d H:i:s',$list['end_time']);?></td>
     
      <td class='check_team'  ><!-- action="index.php?act=store_groupbuy&op=groupbuy_pass_team" -->
      <form method="post" data=<?php echo $list['team_id']; ?> id=<?php echo 'team_form'.$list['team_id'];?> >
          <?php if ($list['status'] == 1 ) echo '<span style="color:green; ">通过</span>';
            else if($list['status'] == 0) {echo '<input  class="status" type="radio" name="status" value="1" />通过'; 
                echo '<input type="radio" class="status" name="status" value="2" />不通过 ';}
            else if($list['status'] == 2) echo '<span style="color:red;">不通过</span>';?></td>
          </tr>
           <input type="hidden" name='team_id' value="" >
           <!-- <input type="hidden" name='groupbuy_id' value=<?php //echo $list['groupbuy_id'];?> > -->
       </form>
         <?php }}?>
  
  </tbody>

</table>



<script type="text/javascript">
$(function(){
		$(".status").click(function(){
			$("input[name='team_id']").val($(this).parents('form').attr('data'));

			$("#team_form"+$(this).parents('form').attr('data')).submit();
			
		});
	 


	 $('.price_check').click(function(){
			var start_time=$(this).parent().siblings('#start_time').text();
			var end_time=$(this).parent().siblings('#end_time').text();
			var range_start=$(this).parent().siblings('#range_start').text();
			var range_end=$(this).parent().siblings('#range_end').text();

			$("input[name='start_time']").val(start_time);
			$("input[name='end_time']").val(end_time);
			$("input[name='range_start']").val(range_start);
			$("input[name='range_end']").val(range_end);

			//首先判断改活动是否结束
			// 获取当前时间戳(以s为单位)
		 	var now = Date.parse(new Date());
		 	now = now / 1000;

		 	var end_time = end_time;
		 	var end_time = Date.parse(new Date(end_time));
		 	
			if(start_time==''){
				alert('请先选择团购活动');return false;
			} else if(now>end_time){
				alert('该团购活动已结束');return false;
			}  
			
		});
});

</script>

